
<form id="form" action="{:url('allwin/shop/add')}">
<input type="hidden" id="store_id" name="store_id" />
<input type="hidden" id="amout" name="amout" value="0"/>
<div class="titlebar"><i class="iconfont icon-license"></i>社群设置</div>
<table class="formtable">
    <tr>
        <th>经纪人:</th>
        <td>
            <input readonly="readonly" id="detective_uid" class="readonly input w100" type="text" name="detective_uid"  />
            <button url="{:url('allwin/store/selectStoreManage')}" data="detective_uid" type="button" class="selectid button"><i class="iconfont icon-my_icon"></i>选择经纪人</button>
            <span class="gray">选择经纪人后每单商品交易都将分成</span>
        </td>
    </tr>
        <th>绑定应答:</th>
        <td>
            <input readonly="readonly" id="keyword" class="readonly input w100" type="text" name="keyword" />
            <button url="{:url('system/passport.keyword/selectOfficial')}" data='keyword' type="button" class="selectid button"><i class="iconfont icon-my_icon"></i>选择应答</button>
            <span class="gray">输入关键字,自动回复客服信息</span>
        </td>
    </tr>
    <tr><th>社群名称:</th><td><input class="input w500" datatype="*" type="text" name="group_title" /></td></tr>
    <tr><th>社群简述:</th><td><input class="input w500" datatype="*" type="text" name="group_note" /></td></tr>
    <tr><th>社群Logo:</th><td><input url="{:url('system/passport.common/upload')}" class="input selectid" id="group_img" datatype="*" type="text" name="group_img" /></td></tr>
</table>
<div class="titlebar"><i class="iconfont icon-store_icon"></i>所属好店</div> 
<table class="formtable">
    <tr><th>所属好店:</th><td><div class="ext-select w500 selectid" id="store_name" url="{:url('allwin/store/selectStore')}">请选择所属商家</div></td></tr>
    <tr>
        <th>商品属性:</th>
        <td class="input-group">
        <select datatype="*" class="select w250" name="types">
            <option value="0">默认属性</option>
            <option value="1">首页横栏</option>
            <option value="2">专题引荐</option>
            <option value="3">精选专栏</option>
            <option value="4">好店推荐</option>
        </select>
        <select id="category_id" class="select w250" datatype="*" name="category_id" class="select">
            <option value="">选择专题</option>
            {foreach $cate as $vo}<option value="{$vo.id}">{$vo.title}</option>{/foreach}
        </select>
        </td>
    </tr>
</table>
<div class="titlebar"><i class="iconfont icon-edit"></i>价格规则 <span class="gray">活动商家收到的金额是你填写的成本价</span></div> 
<table class="formtable">
    <tr><th>实际付款(￥):</th><td><span class="blue" id="price">0</span><span class="gray"> (销售价￥ - 会员省￥ - 优惠券) = 实际付款</span></td></tr>
    <tr><th>实际到账(￥):</th><td><span class="red" id="realamout">0</span> <span class="gray">实际付款 - 引荐所得 - 经纪人所得 = 实际到账</span></td></tr>
    <tr><th>基础价格:</th><td class="input-group">
        <label class="fn-left">成本价(￥)</label><input placeholder="成本价(￥)" class="input w90" datatype="npot" type="text" name="cost_price" /> 
        <label class="fn-left">市场价(￥)</label><input placeholder="市场价(￥)" class="input w90" datatype="npot" type="text" name="market_price" />
        <label class="fn-left fn-fb">销售价(￥)</label><input placeholder="销售价(￥)" class="input w90 calculate" datatype="npot" type="text" name="sell_price" />
    </td></tr>
    <tr><th>会员优惠:</th><td><input class="input w90 calculate" datatype="npot" type="text" name="vip_price" /> <span class="gray">请填写会员减去多少钱</span></td></tr>
    <tr><th>抵扣积分:</th><td><input class="input w90" datatype="n" type="text" name="points" value="0" /> <span class="gray">可以用积分减免多少钱,100积分 = 1元</span></td></tr>
    <tr><th>绑定优惠券:</th><td class="input-group">
        <input id="coupon_id" readonly placeholder="优惠券" class="input w120 calculate readonly" datatype="n" type="text" name="coupon_id" value="0"/>
        <button type="button" class="selectid button" url="{:url('allwin/coupon/selectId',['is_platform' => 0,'input'=>'coupon_id'])}">选择优惠券</button>
        <button type="button" class="button button-blue reset">清空</button>
    </td></tr>
    <tr><th>商品分润:</th><td class="input-group">
        <label class="fn-left">引荐所得(%)</label><input class="input w160 calculate" datatype="npot" type="text" name="share_price" value="0" />
        <label class="fn-left">经纪人所得(%)</label><input class="input w160 calculate" datatype="npot" type="text" name="detective_price" value="0"/>
    </td></tr>
    <tr><th>结束日期:</th><td><input class="input w500 ui-time readonly" type="text" name="end_time" value="" readonly/></td></tr>
</table>
<div class="titlebar"><i class="iconfont icon-edit"></i>商品信息</div> 
  <table class="formtable">
    <tr><th><span class="red">*</span> 产品标题:</th><td><input class="input w500" datatype="*" type="text" name="name" value="" /></td></tr>
    <tr><th><span class="red">*</span> 推荐简述:</th><td><input class="input w500" datatype="*" type="text" name="title" value=""/></td></tr>
    <tr><th><span class="red">*</span> 产品库存:</th><td>
        <input class="input w90" datatype="n" type="text" name="warehouse_num"  /> <span class="gray">0代表已经售完</span>
        <input class="input w90" datatype="n" type="text" name="warehouse_sellnum" value="0"/> <span class="gray">虚拟已售</span>
    </td></tr>
    <tr class="imgs">
        <th><input type="hidden" name="img" id="img_index" />产品预览图</th>
        <td id="imgbox"><div url="{:url('system/passport.common/upload')}" class="selectid img-review fn-left fn-cp product"><img src="__PUBLIC__/admin/review.png"></div></td>
    </tr>
    <tr><th>购买须知</th><td><textarea class="textarea ui-mieditor" id="notice" name="notice"></textarea></td></tr>
    <tr><th>商品详情</th><td><textarea class="textarea ui-editor" id="content" name="content"></textarea></td></tr>
    <tr><th></th><td><input type="submit" value="确定" class="button button-blue submit" /> <input type="reset" value="重置" class="button button-blank" /></td></tr>
</table>
</form>
<script type="text/javascript">
Do('base','layer','form','editor','tpl','date',function () {
    $('#form').isForm({'upload':'{:url("system/passport.common/upload")}'});
    $(".selectid").win();
    $(".calculate").change(function(){
        calculate();
    });
    $(".reset").click(function(){
        $("input[name='coupon_id']").val(0)
        calculate();
    }); 
})
function calculate(){
    var sell_price = parseFloat($("input[name='sell_price']").val()),sell_price = isNaN(sell_price)?0:sell_price;
    var vip_price = parseFloat($("input[name='vip_price']").val()),vip_price = isNaN(vip_price)?0:vip_price;
    var share_price = parseFloat($("input[name='share_price']").val()),share_price = isNaN(share_price)?0:share_price;
    var detective_price = parseFloat($("input[name='detective_price']").val()),detective_price = isNaN(detective_price)?0:detective_price;
    var coupon_id    = parseFloat($("input[name='coupon_id']").val()),coupon_id = isNaN(coupon_id)?0:coupon_id;
    var points    = parseFloat($("input[name='points']").val()),points = isNaN(points)?0:points;
    var points = points/100,price = sell_price-vip_price-points;
    if(coupon_id > 0){
        $.getJSON('{:url("allwin/shop/calculatePrice")}',{coupon_id:coupon_id,sell_price:sell_price},function (rel) {
            price = price-parseFloat(rel.data);
            var amout = (price-(price*share_price/100)-(price*detective_price/100)).toFixed(2)
            $("#price").html(price.toFixed(2));
            $("#amout").val(amout);
            $("#realamout").html(amout);
        });
    }else{
        var amout = (price-(price*share_price/100)-(price*detective_price/100)).toFixed(2)
        $("#price").html(price.toFixed(2));
        $("#amout").val(amout);
        $("#realamout").html(amout);
    }
}
function setState(store){
    $("#store_id").val(store.id);
    $("#store_name").html(store.store_name);
}
function group_img(img){
    $("#group_img").val(img);
}
</script>